#include "admindata.h"

//AdminData::AdminData()
//{
////    semDuration=sem;

//    //    daysOff-> QVector<DateRange>();

//    //    *oSections=new QVector<OutlineSection>();

//    //    *coursesOffered=new QVector<Course>();
//}


//DateRange AdminData::getSemester()
//{
//    return this->semDuration;
//}



//void AdminData::addOutlineSection(OutlineSection oS)
//{
//    oSections.append(oS);
//}




//int AdminData::removeOutlineSection(OutlineSection oSRem)
//{
//    int i=0;
//    while(i<oSections.size())
//    {
//        OutlineSection dummy=oSections.at(i);

//        if(dummy.getTitle().compare(oSRem.getTitle())==0)
//        {
//            if(dummy.getDescription().compare(oSRem.getDescription())==0)
//            {
//                if(dummy.getComments().compare(oSRem.getComments())==0)
//                {
//                    oSections.remove(i);
//                    return 1;
//                }
//            }
//        }
//        i++;
//    }
//    return 0;

//}



//void AdminData::addCourse(Course setCourse)
//{
//    coursesOffered.append(setCourse);
//}





//int AdminData::setSemester(DateRange thisSem)
//{
//    if(thisSem.getStartDate().operator >=(thisSem.getEndDate()))
//    {
//        return 0;
//    }
//    else
//    {
//        semDuration=thisSem;
//        return 1;
//    }
//}


//int AdminData::setDaysOff(DateRange days)
//{
//    if(days.getStartDate().operator <(semDuration.getStartDate()) ||
//            days.getEndDate().operator >(semDuration.getEndDate()))
//    {
//        return 0;
//    }
//    else if(days.getStartDate().operator >=(days.getEndDate()))
//    {
//        return 0;
//    }
//    else
//    {
//        daysOff.append(days);
//        return 1;
//    }
//}

////DateRange AdminData::checkGivenHoliday(QString holName)
////{

////    int i=0;  QDate startDays, QDate endDays, QString name
////    while(daysOff.at(i).getName().compare(holName)
////and more if needed
////}

//int AdminData::removeDaysOff(DateRange days)
//{

//    int i=0;
//    while(i<daysOff.size())
//    {
//        DateRange dummy=daysOff.at(i);
//        if(dummy.getStartDate().operator ==(days.getStartDate()))
//        {
//            if(dummy.getEndDate().operator ==(days.getEndDate()))
//            {
//                if(dummy.getName().compare(days.getName())==0)
//                {
//                    daysOff.remove(i);
//                    return 1;
//                }
//            }
//        }
//        i++;
//    }
//    return 0;
//}


//int AdminData::removeCourse(Course byeCourse)
//{
//    int i=0;
//    while(i<coursesOffered.size())
//    {
//        Course dummy=coursesOffered.at(i);
//        if(dummy.getCode().compare(byeCourse.getCode()))
//        {
//            if(dummy.getName().compare(byeCourse.getName()))
//            {

//                    coursesOffered.remove(i);
//                    return 1;

//            }
//        }
//        i++;
//    }
//    return 0;
//}




////DateRange semDuration;
////QVector<DateRange> daysOff;
////QVector<OutlineSection> oSections;
////QVector<Course> coursesOffered;


////void AdminData::setSemester(QString newName)
////{
////    name=newName;
////}

AdminData::AdminData()
{

}

AdminData::AdminData(const DateRange semDuration,
                     const QVector<DateRange> daysOff,
                     const QVector<OutlineSection> outlineSections,
                     const QVector<Course> courses,
                     const QVector<Professor> profs,
                     const QVector<User> users)
{
    this->semDuration=semDuration;
    this->daysOff = daysOff;
    this->outlineSections = outlineSections;
    this->courses = courses;
    this->profs = profs;
    this->users = users;
}

//AdminData::AdminData(const QVector<User> &users, const QVector<Professor> &profs, const QVector<DateRange> &daysOff)
//{
//    this->users = users;
//    this->profs = profs;
//    this->daysOff = daysOff;
//}
//AdminData::AdminData(const QVector<User> &users, const QVector<Professor> &profs, const QVector<DateRange> &daysOff, const QVector<OutlineSection> &outlineSections)
//{
//    this->users = users;
//    this->profs = profs;
//    this->daysOff = daysOff;
//    this->outlineSections=outlineSections;
//}

//AdminData::AdminData(   const QVector<DateRange> &daysOff,
//                        const QVector<OutlineSection> &outlineSections,
//                        const QVector<Course> &courses,
//                        const QVector<Professor> &profs,
//                        const QVector<User> &users)
//{
//    this->daysOff = daysOff;
//    this->outlineSections = outlineSections;
//    this->courses = courses;
//    this->profs = profs;
//    this->users = users;
//}

DateRange AdminData::getSemDuration() const
{
    return (this->semDuration);
}

QVector<DateRange> AdminData::getDaysOff() const
{
    return this->daysOff;
}

QVector<OutlineSection> AdminData::getOutlineSections() const
{
    return this->outlineSections;
}

QVector<Course> AdminData::getCourses() const
{
    return this->courses;
}

QVector<Course> AdminData::getCourses()
{
    return this->courses;
}

QVector<Professor> AdminData::getProfs() const
{
    return this->profs;
}

QVector<User> AdminData::getUsers() const
{
    return this->users;
}



//DateRange* AdminData::getSemDuration2()
//{
//    return (this->semDuration);
//}

//QVector<DateRange> AdminData::getDaysOff2()
//{
//    return this->daysOff;
//}

//QVector<OutlineSection> AdminData::getOutlineSections2()
//{
//    return this->outlineSections;
//}

//QVector<Course> AdminData::getCourses2()
//{
//    return this->courses;
//}

//QVector<Professor> AdminData::getProfs2()
//{
//    return this->profs;
//}

//QVector<User> AdminData::getUsers2()
//{
//    return this->users;
//}





void AdminData::setDaysOff(QVector<DateRange> *newDaysOff)
{

    this->daysOff=*newDaysOff;
}

void AdminData::setOutlineSections(QVector<OutlineSection> *newOutlineSections)
{

    this->outlineSections=*newOutlineSections;
}

void AdminData::setCourse(QVector<Course> *newCourses)
{
    this->courses=*newCourses;
}

void AdminData::setProfs(QVector<Professor> *newProfs)
{

    this->profs=*newProfs;
}

void AdminData::setUsers(QVector<User> newUsers)
{

    this->users=newUsers;
}

void AdminData::addDaysOff(DateRange newDaysOff)
{
    this->daysOff.append(newDaysOff);

}

void AdminData::addOutlineSection(OutlineSection newOutlineSection)
{
    this->outlineSections.append(newOutlineSection);
}

void AdminData::addCourse(Course newCourse)
{
    this->courses.append(newCourse);
}

void AdminData::addProf(Professor newProf)
{
    this->profs.append(newProf);

}

void AdminData::addUser(User newUser)
{
    this->users.append(newUser);

}

void AdminData::setSemDuration(DateRange *newSemDur)
{
    (semDuration)=*(newSemDur);
}

QDataStream &operator<<(QDataStream &out, const AdminData &data)
{
    out << data.getSemDuration() << data.getDaysOff() << data.getOutlineSections() << data.getCourses() << data.getProfs() << data.getUsers();
    return out;
}

QDataStream &operator>>(QDataStream &in, AdminData &data)
{
//    QVector<DateRange> daysOff;
//    QVector<OutlineSection> outlineSections;
//    QVector<Course> courses;
//    QVector<Professor> profs;
//    in >> courses >> daysOff >> outlineSections >> profs >> users;
//    data = AdminData(daysOff, outlineSections, courses, profs, users);

    DateRange semDuration;
    QVector<DateRange> daysOff;
    QVector<OutlineSection> outlineSections;
    QVector<Course> courses;
    QVector<Professor> profs;
    QVector<User> users;

    in >> semDuration >> daysOff >> outlineSections >> courses >> profs >> users;
    data = AdminData(semDuration, daysOff, outlineSections, courses, profs, users);
    return in;
}


